package main

import "fmt"

/**
需要进一步理解golang 中数组切片的使用
很方便
*/
func construct2DArray(original []int, m int, n int) [][]int {
	l := len(original)
	if m*n != l {
		return [][]int{}
	}
	year2022 := make([][]int, 0, m)
	for i := 0; i < l; i += n {
		year2022 = append(year2022, original[i:i+n])
	}
	return year2022
}

func main() {
	fmt.Println(construct2DArray([]int{1, 2, 3, 4}, 2, 2))
}
